import java.awt.*;

import javax.swing.*;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class PropertiesEx  extends JDialog{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public PropertiesEx() {
		setTitle("Digital Audio (S/PDIF) Properties");
		setResizable(false);
		setIconImage(Toolkit.getDefaultToolkit().getImage("images/add1.png"));
		setSize(new Dimension(400, 460));
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setLocation((Toolkit.getDefaultToolkit().getScreenSize().width-getWidth())/2, (Toolkit.getDefaultToolkit().getScreenSize().height-getHeight())/2);
		UIManager.LookAndFeelInfo look[]=UIManager.getInstalledLookAndFeels();
		try{
			UIManager.setLookAndFeel(look[3].getClassName());
		}catch(Exception e){
		}
		createTap();
	}
	void createTap(){
		JPanel pn1=new JPanel();
		pn1.setLayout(new BoxLayout(pn1, BoxLayout.Y_AXIS));
		pn1.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10));
		add(pn1);
		JTabbedPane tap=new JTabbedPane();
		tap.addTab("General", createGeneral());
		tap.addTab("Supported Formats", createSupported());
		tap.addTab("Levels", createLevel());
		tap.addTab("Enhancements", createEnhancements());
		tap.addTab("Advanced",createAdvanced());
		tap.setPreferredSize(new Dimension(410, 490));
		pn1.add(tap);
		
		JPanel pnbottom=new  JPanel();
		pnbottom.setBorder(BorderFactory.createEmptyBorder(1, 5, 0, -5));
		pnbottom.setLayout(new FlowLayout(FlowLayout.RIGHT,5,5));
		JButton ok=new JButton("OK");
		ok.add(Box.createRigidArea(new Dimension(40, 15)));
		pnbottom.add(ok);
		JButton cancle=new JButton("Cancle");
		cancle.add(Box.createRigidArea(new Dimension(40, 15)));
		pnbottom.add(cancle);
		JButton apply=new JButton("Apply");
		apply.add(Box.createRigidArea(new Dimension(40, 15)));
		pnbottom.add(apply);
		pn1.add(pnbottom);
	}
	JPanel createGeneral(){
		JPanel general=new JPanel();
		general.setLayout(new BoxLayout(general, BoxLayout.X_AXIS));
		
		JPanel pnchung=new JPanel();
		pnchung.setLayout(new FlowLayout(FlowLayout.LEFT));
		JLabel lbtop=new JLabel(new ImageIcon("images/people.png"));
		lbtop.setPreferredSize(new  Dimension(90, 40));
		pnchung.add(lbtop);
		
		JPanel pntop1=new JPanel();
		pntop1.setPreferredSize(new  Dimension(250, 55));
		pntop1.setLayout(new FlowLayout(FlowLayout.LEFT,10,5));
		JTextField txttop=new JTextField("Digital Audio (S/PDIF)");
		txttop.setMargin(new Insets(0, 10, 0, 10));
		txttop.setPreferredSize(new Dimension(230,20));
		txttop.setEditable(true);
		pntop1.add(txttop);
		JButton btntop=new JButton("Change Icon");
		pntop1.add(btntop);
		pnchung.add(pntop1);
		
		JPanel pncen1=new JPanel();
		pncen1.setLayout(new FlowLayout(FlowLayout.LEFT,15,0));
		pncen1.setPreferredSize(new Dimension(355, 70));
		pncen1.setBorder(new TitledBorder(new EtchedBorder(), "Controller Infomation"));
		JLabel lbcen1=new JLabel(new ImageIcon("images/people.png"));
		lbcen1.setPreferredSize(new  Dimension(50, 40));
		pncen1.add(lbcen1);
		
		JPanel pncen1_2=new JPanel();
		pncen1_2.setPreferredSize(new  Dimension(140, 40));
		JLabel lbcen2=new JLabel("High Definition Audio Device");
		lbcen2.setPreferredSize(new Dimension(140, 20));
		pncen1_2.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
		pncen1_2.add(lbcen2);
		
		JLabel lbcen3=new JLabel("Microsoft");
		lbcen3.setForeground(Color.blue);
		lbcen3.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
		pncen1_2.add(lbcen3);
		pncen1.add(pncen1_2);
		
		JPanel pncen1_3=new JPanel();
		pncen1_3.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
		pncen1_3.setLayout(new BoxLayout(pncen1_3, BoxLayout.Y_AXIS));
		JButton properties=new JButton("Properties");
		pncen1_3.add(properties);
		JLabel a=new JLabel();
		a.setPreferredSize(new Dimension(50,20));
		pncen1_3.add(a);
		pncen1.add(pncen1_3);
		pnchung.add(pncen1);
		
		JPanel pncen2=new JPanel();
		pncen2.setPreferredSize(new Dimension(355, 60));
		pncen2.setLayout(new FlowLayout(FlowLayout.LEFT,70,7));
		pncen2.setBorder(new  TitledBorder(new EtchedBorder(),"Jack Information"));
		pncen2.add(new JLabel("ATAPI Internal ATAPI Jack",new ImageIcon("images/people.png"),JLabel.CENTER));
		pnchung.add(pncen2);
		
		JPanel pnbottom=new JPanel();
		pnbottom.setLayout(new FlowLayout(FlowLayout.LEFT,10,120));
		JLabel lbbottom=new JLabel("Device usage:");
		lbbottom.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 50));
		pnbottom.add(lbbottom);
		
		JComboBox<String> com=new JComboBox<String>(new String[]{"Use this device (enable)","Don't use this device (enable)"});
		com.setPreferredSize(new Dimension(200, 20));
		pnbottom.add(com);
		pnchung.add(pnbottom);
		
		general.add(pnchung);
		return pnchung;
	}
	JPanel createSupported(){
		JPanel supported=new JPanel();
		supported.setLayout(new BoxLayout(supported, BoxLayout.Y_AXIS));
		
		JPanel pnchung=new JPanel();
		pnchung.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
		String text1="Which of the following formats is your Digital Receiver able to";
		String text2="decode?";
		
		JPanel pnchung1=new JPanel();
		pnchung1.setLayout(new BoxLayout(pnchung1, BoxLayout.Y_AXIS));
		pnchung1.setBorder(new TitledBorder(new EtchedBorder(),"Encoded formats"));
		pnchung.add(pnchung1);
		
		JPanel pntop=new JPanel();
		pntop.setLayout(new FlowLayout(FlowLayout.LEFT,5,0));
		pntop.setPreferredSize(new Dimension(320, 40));
		JLabel lb1=new JLabel(text1);
		lb1.setPreferredSize(new Dimension(320, 20));
		JLabel lb2=new JLabel(text2);
		lb2.setPreferredSize(new Dimension(320, 20));
		pntop.add(lb1);
		pntop.add(lb2);
		pnchung1.add(pntop);
		
		JPanel pncen=new JPanel();
		pncen.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
		JPanel pncen1=new JPanel();
		pncen1.setLayout(new BoxLayout(pncen1, BoxLayout.Y_AXIS));
		pncen1.setBorder(BorderFactory.createEmptyBorder(0, -5, 0, 0));
		JCheckBox check1=new JCheckBox(" DTS Audio");
		check1.setSelected(true);
		check1.add(Box.createRigidArea(new Dimension(80,5)));
		JCheckBox check2=new JCheckBox(" Dollby Digital");
		check2.setSelected(true);
		check2.add(Box.createRigidArea(new Dimension(80,5)));
		JCheckBox check3=new JCheckBox(" Microsoft WMA Pro Audio");
		check3.add(Box.createRigidArea(new Dimension(140,5)));
		pncen1.add(check1);
		pncen1.add(check2);
		pncen1.add(check3);
		JScrollPane sroll=new JScrollPane(pncen1);
		sroll.setPreferredSize(new Dimension(225, 70));
		pncen.add(sroll);
		JPanel pncen1_2=new JPanel();
		pncen1_2.setLayout(new BoxLayout(pncen1_2, BoxLayout.Y_AXIS));
		pncen1_2.add(new JButton("Test", new ImageIcon("images/add.png")));
		JLabel lbtrung=new JLabel();
		lbtrung.setPreferredSize(new Dimension(10, 50));
		pncen1_2.add(lbtrung);
		pnchung1.add(pncen);
		pncen.add(pncen1_2);
		pnchung1.add(pntop);
		pnchung1.add(pncen);
		
		String text3="Which of the following sample rates are supported by your";
		String text4="Digital Receiver?";
		
		JPanel pnchung2=new JPanel();
		pnchung2.setLayout(new BoxLayout(pnchung2, BoxLayout.Y_AXIS));
		pnchung2.setBorder(new TitledBorder(new EtchedBorder(),"Sample Rates"));
		pnchung.add(pnchung2);
		
		JPanel pnbottom=new JPanel();
		pnbottom.setLayout(new FlowLayout(FlowLayout.LEFT,5,0));
		pnbottom.setPreferredSize(new Dimension(320, 40));
		
		JLabel lb3=new JLabel(text3);
		lb3.setPreferredSize(new Dimension(320, 20));
		JLabel lb4=new JLabel(text4);
		lb4.setPreferredSize(new Dimension(320, 20));
		pnbottom.add(lb3);
		pnbottom.add(lb4);
		pnchung2.add(pnbottom);
		
		JPanel pncen2=new JPanel();
		pncen2.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
		
		JPanel pncen3=new JPanel();
		pncen3.setLayout(new BoxLayout(pncen3, BoxLayout.Y_AXIS));
		pncen3.setBorder(BorderFactory.createEmptyBorder(0, -5, 0, 0));
		JCheckBox check4=new JCheckBox(" 44.1 kHz");
		check4.setSelected(true);
		check4.add(Box.createRigidArea(new Dimension(70,5)));
		JCheckBox check5=new JCheckBox(" 48.0 kHz");
		check5.setSelected(true);
		check5.add(Box.createRigidArea(new Dimension(70,5)));
		JCheckBox check6=new JCheckBox(" 96.0 kHz");
		check6.add(Box.createRigidArea(new Dimension(70,5)));
		pncen3.add(check4);
		pncen3.add(check5);
		pncen3.add(check6);
		JScrollPane sroll1=new JScrollPane(pncen3);
		sroll1.setPreferredSize(new Dimension(225, 70));
		pncen2.add(sroll1);
		JPanel pncen3_1=new JPanel();
		pncen3_1.setLayout(new BoxLayout(pncen3_1, BoxLayout.Y_AXIS));
		JButton a=new JButton("Test", new ImageIcon("images/add.png"));
		a.setEnabled(false);
		pncen3_1.add(a);
		JLabel lbtrung1=new JLabel();
		lbtrung1.setPreferredSize(new Dimension(10, 50));
		pncen3_1.add(lbtrung1);
		pncen2.add(pncen3_1);
		pnchung2.add(pncen2);
		pnchung.add(pnchung2);
		
		
		supported.add(pnchung);
		return supported;
	}
	JTextField text;
	JSlider slider;
	JPanel createLevel(){
		
		JPanel level=new JPanel();
		//level.setLayout(new BoxLayout(level, BoxLayout.Y_AXIS));
		JPanel pnchung =new JPanel();
		pnchung.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
		pnchung.setPreferredSize(new Dimension(340, 80));
		pnchung.setBorder(new TitledBorder(new EtchedBorder(),"Digital Audio (S/PDIF)"));
		JLabel ab=new JLabel();
		ab.setPreferredSize(new Dimension(400, 10));
		level.add(ab);
		
		level.add(pnchung);
		
		slider=new JSlider(JSlider.CENTER,0,100,1);
		slider.setPreferredSize(new Dimension(140, 50));
		slider.setMajorTickSpacing(50);
		slider.setMinorTickSpacing(50);
		slider.addChangeListener(new ChangeListener() {
			@Override
			public void stateChanged(ChangeEvent arg0) {
				int a=slider.getValue();
				text.setText(""+a);
			}
		});
		slider.setPaintTicks(true);
		pnchung.add(slider);
		text=new JTextField("0");
		text.setPreferredSize(new Dimension(40, 20));
		text.setHorizontalAlignment(JTextField.RIGHT);
		text.setEditable(false);
		pnchung.add(text);
		JButton btn1=new JButton(new ImageIcon("images/save.png"));
		btn1.setPreferredSize(new Dimension(25, 25));
		JButton btn2=new JButton("Balance");
		btn2.setPreferredSize(new Dimension(70, 25));
		pnchung.add(btn1);
		pnchung.add(btn2);
		return level;
	}
	JPanel createEnhancements(){
		JPanel enhancements=new JPanel();
		enhancements.setLayout(new BoxLayout(enhancements, BoxLayout.Y_AXIS));
		JPanel pnchung=new JPanel();
		pnchung.setLayout(new FlowLayout(FlowLayout.LEFT,9,10));
		enhancements.add(pnchung);
		
		JPanel pntop=new JPanel();
		pntop.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
		pntop.setPreferredSize(new Dimension(400, 45));
		JLabel lbtop1=new JLabel("Select the enhancements to apply for your current speaker");
		JLabel lbtop2=new JLabel("configuration. Changes may not take effect until the next time you start");
		JLabel lbtop3=new JLabel("playback.");
		lbtop3.setPreferredSize(new Dimension(100, 15));
		pntop.add(lbtop1);
		pntop.add(lbtop2);
		pntop.add(lbtop3);
		pnchung.add(pntop);
		
		JPanel pncen1=new JPanel();
		pncen1.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
		pncen1.setPreferredSize(new Dimension(380, 110));
		pnchung.add(pncen1);
		JCheckBox check1=new JCheckBox("Disable all enhancments");
		pncen1.add(check1);
		
		JPanel pncheck=new JPanel();
		pncheck.setLayout(new FlowLayout(FlowLayout.LEFT,5,0));
		pncheck.setBorder(new EtchedBorder());
		pncheck.setPreferredSize(new Dimension(350, 85));
		pncen1.add(pncheck);
		JCheckBox check2=new JCheckBox("Low Frequency Protection");
		check2.add(Box.createRigidArea(new Dimension(250, 10)));
		JCheckBox check3=new JCheckBox("Virtual Surround");
		check3.add(Box.createRigidArea(new Dimension(250, 10)));
		JCheckBox check4=new JCheckBox("Room Correction");
		check4.add(Box.createRigidArea(new Dimension(250, 10)));
		JCheckBox check5=new JCheckBox("Loudness Equalization");
		check5.add(Box.createRigidArea(new Dimension(150, 10)));
		pncheck.add(check2);
		pncheck.add(check3);
		pncheck.add(check4);
		pncheck.add(check5);
		
		JPanel pncen2=new JPanel();
		pncen2.setLayout(new FlowLayout(FlowLayout.LEFT));
		pncen2.setPreferredSize(new Dimension(352, 130));
		pncen2.setBorder(new TitledBorder(new EtchedBorder(),"Enhancement Propertise"));
		pnchung.add(pncen2);
		JLabel lbac=new JLabel();
		lbac.setPreferredSize(new Dimension(20, 0));
		pncen2.add(lbac);
		
		JPanel pncen2_1=new JPanel();
		pncen2_1.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
		pncen2_1.setPreferredSize(new Dimension(300, 50));
		pncen2.add(pncen2_1);
		JPanel pntrung=new JPanel();
		pntrung.setPreferredSize(new Dimension(58, 70));
		pntrung.setLayout(new BoxLayout(pntrung, BoxLayout.Y_AXIS));
		pncen2_1.add(pntrung);
		JLabel lbcen1=new JLabel("Description:");
		lbcen1.setPreferredSize(new Dimension(40, 15));
		pntrung.add(lbcen1);
		JLabel lbcen2=new JLabel();
		lbcen1.setPreferredSize(new Dimension(40, 70));
		pntrung.add(lbcen2);
		
		JPanel pncen2_1_1=new JPanel();
		pncen2_1_1.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
		pncen2_1_1.setPreferredSize(new Dimension(220, 70));
		pncen2_1.add(pncen2_1_1);
		JLabel lbcen2111=new JLabel("Loudness Equalization users understanding of");
		lbcen2111.setPreferredSize(new Dimension(220, 15));
		JLabel lbcen2112=new JLabel("human hearing to reduce perceived volume");
		lbcen2112.setPreferredSize(new Dimension(220, 15));
		JLabel lbcen2113=new JLabel("differences.");
		pncen2_1_1.add(lbcen2111);
		pncen2_1_1.add(lbcen2112);
		pncen2_1_1.add(lbcen2113);
		
		JPanel pncen2_1_2=new  JPanel();
		pncen2_1_2.setLayout(new FlowLayout(FlowLayout.LEFT,50,0));
		pncen2_1_2.setPreferredSize(new Dimension(330,40));
		pncen2.add(pncen2_1_2);
		JPanel pngiuacuoi=new JPanel();
		pngiuacuoi.setLayout(new BoxLayout(pngiuacuoi, BoxLayout.Y_AXIS) );
		pngiuacuoi.setPreferredSize(new Dimension(100,40));
		pncen2_1_2.add(pngiuacuoi);
		JLabel lbgiuacuoi1=new JLabel("Provider: Microsoft");
		lbgiuacuoi1.setPreferredSize(new Dimension(50, 80));
		JLabel lbgiuacuoi2=new JLabel("Status: Disabled");
		lbgiuacuoi2.setPreferredSize(new Dimension(50, 80));
		lbgiuacuoi2.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
		pngiuacuoi.add(lbgiuacuoi1);
		pngiuacuoi.add(lbgiuacuoi2);
		
		JPanel pnphaicuoi=new JPanel();
		pnphaicuoi.setLayout(new FlowLayout(FlowLayout.LEFT,50,-2));
		pnphaicuoi.setPreferredSize(new Dimension(130,40));
		pncen2_1_2.add(pnphaicuoi);
		JLabel btn1=new JLabel();
		btn1.setPreferredSize(new Dimension(70, 18));
		JButton btn2=new JButton("Settings..");
		pnphaicuoi.add(btn1);
		pnphaicuoi.add(btn2);

		
		JPanel pnbottom=new JPanel();
		pnbottom.setLayout(new FlowLayout(FlowLayout.LEFT,0,10));
		pnbottom.add(new JButton("Restore Defaults"));
		JLabel lbcuoi=new JLabel();
		lbcuoi.setPreferredSize(new Dimension(135, 1));
		pnbottom.add(lbcuoi);
		JComboBox<String> com=new JComboBox<String>();
		com.setPreferredSize(new Dimension(100, 22));
		pnbottom.add(com);

		pnchung.add(pnbottom);
		return enhancements;
	}
	JPanel createAdvanced(){
		JPanel advanced=new JPanel();
		advanced.setLayout(new BoxLayout(advanced, BoxLayout.Y_AXIS));
		JPanel pnchung=new JPanel();
		pnchung.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
		advanced.add(pnchung);
		
		JPanel pntop=new JPanel();
		pntop.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
		pntop.setBorder(new TitledBorder(new EtchedBorder(),"Default Format"));
		pntop.setPreferredSize(new Dimension(350, 110));
		pnchung.add(pntop);
		
		JLabel lb1=new JLabel("Select the sample rate and bit depth to be used when running");
		lb1.setPreferredSize(new Dimension(320, 20));
		lb1.setBorder(BorderFactory.createEmptyBorder(0, 0, -4, 0));
		JLabel lb2=new JLabel("in shared mode");
		lb2.setBorder(BorderFactory.createEmptyBorder(0, 0, -4, 0));
		lb2.setPreferredSize(new Dimension(100, 20));
		pntop.add(lb1);
		pntop.add(lb2);
		
		JPanel pntop1=new JPanel();
		pntop1.setLayout(new FlowLayout(FlowLayout.LEFT,0,10));
		pntop1.setPreferredSize(new Dimension(330, 34));
		JComboBox<String> com=new JComboBox<String>(new String[]{"2 channel,16bit,44100 Hz (CD Quality)","2 channel,16bit,48000 Hz (DVD Quality)"});
		com.setPreferredSize(new Dimension(210, 20));
		JButton btn=new JButton("Test", new ImageIcon("images/add1.png"));
		btn.add(Box.createRigidArea(new Dimension(50, 14)));
		JLabel lb3=new JLabel();
		lb3.setPreferredSize(new Dimension(25, 20));
		pntop1.add(com);
		pntop1.add(lb3);
		pntop1.add(btn);
		pntop.add(pntop1);
		
		JPanel pnbottom=new JPanel();
		pnbottom.setLayout(new BoxLayout(pnbottom, BoxLayout.Y_AXIS));
		pnbottom.setBorder(new TitledBorder(new EtchedBorder(),"Exclusive Mode"));
		pnbottom.setPreferredSize(new Dimension(350, 60));
		JCheckBox check1=new JCheckBox("Allow application to take exclusive control of this device");
		check1.setSelected(true);
		check1.add(Box.createRigidArea(new Dimension(300,10)));
		JCheckBox check2=new JCheckBox("Give exclusive mode application priority");
		check2.setSelected(true);
		check2.add(Box.createRigidArea(new Dimension(250,10)));
		pnbottom.add(check1);
		pnbottom.add(check2);
		pnchung.add(pnbottom);
		
		
		JPanel pncuoi=new JPanel();
		pncuoi.setLayout(new FlowLayout(FlowLayout.LEFT,0,130));
		JButton btn1=new JButton("Restore Defaults");
		btn1.setEnabled(false);
		pncuoi.add(btn1);
		pnchung.add(pncuoi);
		return advanced;
	}
}
